﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Silvermoon.Controls.Forms;
using Silvermoon.Core;

namespace Silvermoon.Utils
{
    internal static class ExitAppUtil
    {
        private static bool isDialogShown;
        public static void Exit()
        {
            if (!isDialogShown)
            {
                isDialogShown = true;
                MessageDialog.Show("Exit application?", "", "Exit", "Cancel", OnExit, OnCancel);
                isDialogShown = true;
            }
        }

        private static void OnCancel()
        {
            isDialogShown = false;
        }

        private static void OnExit()
        {
            isDialogShown = false;
            Screen screen = Screen.Current;
            if (screen != null) screen.Close();
        }
    }
}
